package com.api.openfeign.factory;

import com.api.openfeign.client.UserClient;
import com.api.openfeign.dto.UserDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class UserFallback implements FallbackFactory<UserClient> {
    @Override
    public UserClient create(Throwable cause) {
        //log.error("创建 UserClient 的降级实例，原因: ", cause);
        return new UserClient() {
            @Override
            public UserDto username(String username) {
                log.warn("调用 auth-service 的 username 方法降级，参数: {}, 原因: {}", username, cause.getMessage());
                System.out.println("降级处理");
                return null;
            }

            @Override
            public UserDto userId(Long user_id) {
                return null;
            }
        };
    }
}

